package cn.gdcp.listviewcustomadapter;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    private ListView nameListView;
    private ArrayList<Student> studentArrayList = new ArrayList<>();
    private MyAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initStuList();

        nameListView = findViewById(R.id.name_ListView);

        adapter = new MyAdapter(MainActivity.this,studentArrayList);

        nameListView.setAdapter(adapter);
    }

    private void initStuList(){
        Student s1 = new Student(R.drawable.thor,"雷神",19);
        Student s2 = new Student(R.drawable.ironman,"钢铁侠",20);
        Student s3 = new Student(R.drawable.captain,"美国队长",21);
        Student s4 = new Student(R.drawable.thehulk,"绿巨人",22);
        Student s5 = new Student(R.drawable.scarletwitch,"绯红女巫",23);
        Student s6 = new Student(R.drawable.doctor,"奇异博士",24);
        Student s7 = new Student(R.drawable.visus,"幻视",25);
        Student s8 = new Student(R.drawable.starlord,"星爵",26);
        Student s9 = new Student(R.drawable.blackwidow,"黑寡妇",27);
        Student s10 = new Student(R.drawable.black,"黑豹",28);
        Student s11 = new Student(R.drawable.spiderman,"蜘蛛侠",29);
        Student s12 = new Student(R.drawable.tree,"格鲁特",30);
        Student s13 = new Student(R.drawable.firearrow,"火箭浣熊",31);
        Student s14 = new Student(R.drawable.draxthedestroyer,"毁灭者德拉克斯",32);
        Student s15 = new Student(R.drawable.camorra,"卡魔拉",33);
        Student s16 = new Student(R.drawable.thanos,"灭霸",34);
        studentArrayList.add(s1);
        studentArrayList.add(s2);
        studentArrayList.add(s3);
        studentArrayList.add(s4);
        studentArrayList.add(s5);
        studentArrayList.add(s6);
        studentArrayList.add(s7);
        studentArrayList.add(s8);
        studentArrayList.add(s9);
        studentArrayList.add(s10);
        studentArrayList.add(s11);
        studentArrayList.add(s12);
        studentArrayList.add(s13);
        studentArrayList.add(s14);
        studentArrayList.add(s15);
        studentArrayList.add(s16);
    }

}
